home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / etc / init.d / cups < prev    next >
Text File  |  2009-10-15  |  3KB  |  117 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          cups
  4. # Required-Start:    $syslog
  5. # Required-Stop:     $syslog
  6. # Should-Start:      $network avahi
  7. # Should-Stop:       $network
  8. # X-Start-Before:    samba
  9. # X-Stop-After:      samba
  10. # Default-Start:     2 3 4 5
  11. # Default-Stop:      1
  12. # Short-Description: CUPS Printing spooler and server
  13. ### END INIT INFO
  14.  
  15. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  16. DAEMON=/usr/sbin/cupsd
  17. NAME=cupsd
  18. PIDFILE=/var/run/cups/$NAME.pid
  19. DESC="Common Unix Printing System"
  20.  
  21. unset TMPDIR
  22.  
  23. test -x $DAEMON || exit 0
  24.  
  25. mkdir -p /var/run/cups/certs
  26.  
  27. if [ -r /etc/default/cups ]; then
  28.   . /etc/default/cups
  29. fi
  30.  
  31. . /lib/lsb/init-functions
  32.  
  33. # Get the timezone set.
  34. if [ -z "$TZ" -a -e /etc/timezone ]; then
  35.     TZ=`cat /etc/timezone`
  36.     export TZ
  37. fi
  38.  
  39. restart_xprint() {
  40.     if [ -n "$success" ] && [ -x /etc/init.d/xprint ]; then
  41.         invoke-rc.d xprint force-reload || true
  42.     fi
  43. }
  44.  
  45. coldplug_usb_printers() {
  46.     if type udevadm > /dev/null 2>&1 && [ -x /lib/udev/udev-configure-printer ]; then
  47.     for printer in `udevadm trigger --verbose --dry-run --subsystem-match=usb \
  48.         --attr-match=bInterfaceClass=07 --attr-match=bInterfaceSubClass=01 2>/dev/null || true; \
  49.                     udevadm trigger --verbose --dry-run --subsystem-match=usb 
  50.         --sysname-match='lp[0-9]*' 2>/dev/null || true`; do
  51.         /lib/udev/udev-configure-printer add "${printer#/sys}"
  52.     done
  53.     fi
  54. }
  55.  
  56. case "$1" in
  57.   start)
  58.     log_begin_msg "Starting $DESC: $NAME"
  59.     chown root:lpadmin /usr/share/ppd/custom 2>/dev/null || true
  60.     chmod 3775 /usr/share/ppd/custom 2>/dev/null || true
  61.  
  62.     mkdir -p `dirname "$PIDFILE"`
  63.     if [ "$LOAD_LP_MODULE" = "yes" -a -f /usr/lib/cups/backend/parallel \
  64.              -a -f /proc/devices -a -f /proc/modules -a -x /sbin/modprobe ]; then
  65.       modprobe -q -b lp || true
  66.       modprobe -q -b ppdev || true
  67.     fi
  68.  
  69.     start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" --exec $DAEMON && success=1
  70.  
  71.     coldplug_usb_printers
  72.     log_end_msg $?
  73.     restart_xprint
  74.     ;;
  75.   stop)
  76.     log_begin_msg "Stopping $DESC: $NAME"
  77.     start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME && success=1
  78.     log_end_msg $?
  79.     restart_xprint
  80.     ;;
  81.   reload|force-reload)
  82.        log_begin_msg "Reloading $DESC: $NAME"
  83.        start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME --signal 1 && success=1
  84.        log_end_msg $?
  85.     restart_xprint
  86.        ;;
  87.   restart)
  88.     log_begin_msg "Restarting $DESC: $NAME"
  89.     if start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME; then
  90.         start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec $DAEMON && success=1
  91.     fi
  92.     log_end_msg $?
  93.     restart_xprint
  94.     ;;
  95.   status)
  96.     echo -n "Status of $DESC: "
  97.     if [ ! -r "$PIDFILE" ]; then
  98.         echo "$NAME is not running."
  99.         exit 3
  100.     fi
  101.     if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then
  102.         echo "$NAME is running."
  103.         exit 0
  104.     else
  105.         echo "$NAME is not running but $PIDFILE exists."
  106.         exit 1
  107.     fi
  108.     ;;
  109.   *)
  110.     N=/etc/init.d/${0##*/}
  111.     echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
  112.     exit 1
  113.     ;;
  114. esac
  115.  
  116. exit 0
  117.